<template>
  <view>
	  <view style="width: 100%;"><view style="margin: auto;width: 10%;font-size: 40rpx;font-weight: 600; color: red;">{{ orderInfo.price }}</view></view>
    <view>
	  <zk-pay-column :wayList="payMethods"  @choosePayWay="choosePayWay"></zk-pay-column>
    </view>

    <view class="fix-bottom" style="width: 100%"  >
      <button type="warn" @click="pay()">确定支付</button>
    </view>
  </view>
</template>

<script>
import {mainService} from "../../../api/buyer/main";

export default {
  name: "PayPage",
  onLoad(option) {
    const s = decodeURIComponent(option.orderInfo);
    this.orderInfo = JSON.parse(s)
  },
  data(){
    return{
      value:"微信支付",
      orderInfo:{},
      payMethods:[
        {
          value: 1,
          name: "微信支付",
          url: "/static/images/buyer/pay/wx_pay.png",
        },
        {
          value: 2,
          name: "支付宝支付",
          url: "/static/images/buyer/pay/zfb_pay.png",
        },
        {
          value: 3,
          name: "银联支付",
          url: "/static/images/buyer/pay/yl_pay.png",
        },
      ]
    }
  },
  methods:{
    choosePayWay(item){
      console.log(item)
    },
    pay(){
      uni.showLoading({title: '加载中',mask:true});
      mainService.pay(this.orderInfo.orderId).then((res)=>{
        console.log(res.data)
        uni.hideLoading();
        uni.showToast({
          title: '支付成功',
          duration: 2000
        });
        this.toOrder();
      }).catch(err => {
        uni.showToast({
          title: '支付失败',
          duration: 2000
        });
        uni.hideLoading()
      })
    },
    toOrder(){
      let info={
        status:"待发货",
        type:"pay"
      }
      uni.navigateTo({
        url: '/pages/buyer/public/Order/OrderList?info='+encodeURIComponent(JSON.stringify(info)),
        // url: '/pages/staff/application/production/taskList/task-detail'
      })
    }
  }
}
</script>

<style scoped>

</style>